home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD-ROM Magazine 28 Bonus
/
CDRomMagazine-SoftKey-ArtPassion-FrenchVersion-Win31Mac.bin
/
data
/
arttiml.dir
/
00017_Script_SCROLLBAR SCRIPTS
< prev
next >
Wrap
Text File
|
1996-06-16
|
3KB
|
105 lines
on initScrollBar
global scrollBar,numOfPixelsPerScreen, halfNumPixelsPerScreen,thumb,timeLine,screenWidth
global numberOfScreens,firstTimeScreenframe, framesBetweenScreens
set scrollBar = 36 -- TimeBar
set thumb = 37
set firstTimeScreenframe = 4
set framesBetweenScreens = 2
set numberOfScreens = 40
puppetSprite thumb,1
-- the thumb has to be moved numOfPixelsPerScreen pixels to move the timeLine 1 screen
set scrollBarWidth = the width of sprite scrollBar
set numOfPixelsPerScreen = (scrollBarWidth * 1.0) / (numberOfScreens - 1)
set halfNumPixelsPerScreen = numOfPixelsPerScreen/2
-- restrict movement of thumb to the scrollbar
set the constraint of sprite thumb to scrollBar
end
-------------------------------------------------------------------------------------
-- handler newScreen gets called when clicking on the scrollbar.
--
on newScreen
global thumb,screenWidth
--trace on
repeat while the mouseDown
scroll
end repeat
--trace off
end
-------------------------------------------------------------------------------------
-- handler scroll gets called when dragging the thumb
--
on scroll
global thumb,scrollBar
repeat while the mouseDown
set newLocH = the mouseH
updateLocHOfItem thumb, newLocH
end repeat
updateTimeLine
end
-------------------------------------------------------------------------------------
-- handler updateTimeLine
-- calculates the new timeline screen from the position of the tumb.
-- shows the new timeline screen
-- calculates the thumbposition that corresponds with the new timeline screen
-- snaps the tumb into this new position
on updateTimeLine
global thumb, framesBetweenScreens, firstTimeScreenframe
set newScreen = getScreenNumFromThumbPos()
set newFrame = firstTimeScreenframe + (newScreen - 1) * framesBetweenScreens
put "newScreen = "&newScreen
put "newFrame = "&newFrame
if newFrame > the frame then
goForwardIntime newFrame
else if newFrame < the frame then
goBackIntime newFrame
end if
-- snap thumb to position
set newThumbPos = getThumbPosFromScreenNum(newScreen)
updateLocHOfItem thumb,newThumbPos
end
on getScreenNumFromThumbPos
global thumb,numOfPixelsPerScreen,halfNumPixelsPerScreen, scrollBar, numberOfScreens
set thumbPos = the locH of sprite thumb - the left of sprite scrollBar
-- set screenNum = integer((thumbPos+halfNumPixelsPerScreen) / numOfPixelsPerScreen)
set screenNum = integer(thumbPos / numOfPixelsPerScreen) + 1
if screenNum < 1 then set screenNum = 1
if screenNum > numberOfScreens then set screenNum = numberOfScreens
return screenNum
end
on getThumbPosFromScreenNum aScreen
global numOfPixelsPerScreen,scrollBar
set newLocH = the left of sprite scrollBar + integer((aScreen-1) * numOfPixelsPerScreen)
return newLocH
end
on updateLocHOfItem aSprite, aLocH
set the locH of sprite aSprite to aLocH
updateStage
end